def solve(s):
    n=len(s)
    if n<=1: return n 
    m_len=1
    set0=set(s[0])
    i,j=0,1
    while i<n-m_len:
        while j<n and (s[j] not in set0):
            set0.add(s[j])
            j+=1
        if j-i>m_len:m_len=j-i
        i+=1
        set0.remove(s[i-1])
    return m_len

print(solve('abcabcbb'),solve('bbbbb'),solve('pwwkew'))

